Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #452 +/- ##
=======================================
Coverage 88.98% 88.98%
=======================================
Files 44 44
Lines 6545 6545
=======================================
Hits 5824 5824
Misses 721 721 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
thierry-martinez
left a comment
There was a problem hiding this comment.
Very nice! Thanks. I have some minor remarks. I also question whether we should version uv.lock, since it appears to be a large generated file likely to cause merge conflicts. I'd prefer to stick with our policy of specifying version constraints in pyproject.toml on a case-by-case basis.
docs/source/conf.py
Outdated
|
|
||
| project = "graphix" | ||
| copyright = "2022, Team Graphix" | ||
| copyright = "2026, Team Graphix" |
There was a problem hiding this comment.
We could put a year range: 2022-2026.
| uv run ruff check --select I --fix . | ||
| uv run ruff format . |
There was a problem hiding this comment.
Could we add an equivalent to the code coverage command from before:
uv run pytest --cov=./graphix --cov-report=xml --cov-report=term --doctest-modules
.github/workflows/ruff.yml
Outdated
|
|
||
| - name: Run Ruff Linter | ||
| run: ruff check --output-format=github | ||
| run: uv run --extra dev ruff check --output-format=github |
There was a problem hiding this comment.
Previously, we installed just ruff (constrained by requirements-dev.txt) instead of all dev dependencies: pip install ruff -c requirements-dev.txt
With uv, the equivalent is:
| run: uv run --extra dev ruff check --output-format=github | |
| run: uv run --with ruff ruff check --output-format=github |
.github/workflows/ruff.yml
Outdated
|
|
||
| - name: Run Ruff Formatter Check | ||
| run: ruff format --check | ||
| run: uv run --extra dev ruff format --check No newline at end of file |
There was a problem hiding this comment.
| run: uv run --extra dev ruff format --check | |
| run: uv run --with ruff ruff format --check |
|
|
||
| git clone https://github.com/TeamGraphix/graphix.git | ||
| cd graphix | ||
| uv sync --extra dev --extra extra |
There was a problem hiding this comment.
I would add the step pip install uv, since uv is not part of the standard Python distribution.
| git clone git@github.com:TeamGraphix/graphix.git | ||
| cd graphix | ||
| pip install -e .[dev] | ||
| uv sync --extra dev --extra extra |
There was a problem hiding this comment.
I would recommend to add pip install uv here as well.
CONTRIBUTING.md
Outdated
| ```bash | ||
| pip install .[dev] | ||
| pytest --cov=./graphix --cov-report=xml --cov-report=term | ||
| uv run ruff check --select I --fix . |
There was a problem hiding this comment.
If I understand correctly, the rule I is already selected in pyproject.toml.
| uv run ruff check --select I --fix . | |
| uv run ruff check --fix . |
I would add a point about test coverage: uv run pytest --cov=./graphix --cov-report=xml --cov-report=term --doctest-modules
CONTRIBUTING.md
Outdated
|
|
||
| ```bash | ||
| pip install -e . --config-settings editable_mode=strict | ||
| pip install . --config-settings editable_mode=strict |
There was a problem hiding this comment.
The --config-settings editable_mode=strict flag is only useful with -e (editable installs); it ensures type-checking works correctly with editable packages. I don't know if uv offers an equivalent setting for installing packages as editable while preserving type-checking support.
There was a problem hiding this comment.
The command I've changed it to seems to work. We can also put this in the pyproject.toml to enforce strict editable mode always, but not sure if that's what we want?
pyproject.toml
Outdated
| "pytest-mpl", | ||
| "qiskit>=1.0", | ||
| "qiskit_qasm3_import", | ||
| "qiskit-aer; python_version < '3.14'", |
There was a problem hiding this comment.
This Python version constraint can be removed (see #462).
| "qiskit-aer; python_version < '3.14'", | |
| "qiskit-aer", |
|
|
||
| - name: Run Ruff Linter | ||
| run: ruff check --output-format=github | ||
| run: uv run --with ruff ruff check --output-format=github |
There was a problem hiding this comment.
[:art: text-formatter] reported by reviewdog 🐶
| run: uv run --with ruff ruff check --output-format=github | |
| run: uv run --with ruff ruff check --output-format=github |
|
|
||
| - name: Run Ruff Formatter Check | ||
| run: ruff format --check | ||
| run: uv run --with ruff ruff format --check No newline at end of file |
There was a problem hiding this comment.
[:art: text-formatter] reported by reviewdog 🐶
| run: uv run --with ruff ruff format --check | |
| run: uv run --with ruff ruff format --check |
|
|
||
| These settings enable the linter, format the code on save and turn on basic | ||
| static type checking through the Pylance extension. | ||
| static type checking through the Pylance extension. No newline at end of file |
There was a problem hiding this comment.
[:art: text-formatter] reported by reviewdog 🐶
| static type checking through the Pylance extension. | |
| static type checking through the Pylance extension. |
matulni
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Here are some comments
|
|
||
| We recommend to [fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo) before working on new features, whether that being an existing issue or your own idea. | ||
| Once created, you'll need to clone the repository, and you can follow below to set up the environment. You may want to set up virtual environment, such as `conda env` or `pipenv` before setting up the environment. | ||
| Once created, you'll need to clone the repository, and you can follow below to set up the environment. We recommend you use a virtual environment like `uv`, but you may prefer to use `conda env` or `pipenv`. |
There was a problem hiding this comment.
| Once created, you'll need to clone the repository, and you can follow below to set up the environment. We recommend you use a virtual environment like `uv`, but you may prefer to use `conda env` or `pipenv`. | |
| Once created, you'll need to clone the repository, and you can follow below to set up the environment. We recommend you use a project manager like `uv`, but you may prefer to manage your own virtual environment with `conda env` or `pipenv`. |
| ### Local checks | ||
|
|
||
| To replicate the CI pipeline locally, install `nox` and run the tests: | ||
| You can also run the full CI suite locally: |
There was a problem hiding this comment.
| You can also run the full CI suite locally: | |
| You can also run the full CI test suite locally: |
My understanding is that our nox file doesn't do anything about typecheckers or linters.
| ruff format . | ||
| uv run ruff check . | ||
| uv run ruff format --check . | ||
| uv run mypy |
There was a problem hiding this comment.
| uv run mypy | |
| uv run mypy | |
| uv run pyright |
| Once created, you'll need to clone the repository, and you can follow below to set up the environment. We recommend you use a virtual environment like `uv`, but you may prefer to use `conda env` or `pipenv`. | ||
|
|
||
| ```bash | ||
| git clone git@github.com:<username>/graphix.git |
There was a problem hiding this comment.
I think this was consistent with the recommendation of forking the repo above.
| dependencies = [ | ||
| "matplotlib", | ||
| "networkx", | ||
| "numpy>=2", | ||
| "opt_einsum", | ||
| "quimb", | ||
| "scipy", | ||
| "sympy", | ||
| "typing_extensions", | ||
| ] |
There was a problem hiding this comment.
Should we take the opportunity of this PR to pin all dependencies ?
I believe that this will yield safer and more stable code, not sure if dependabot takes care of updating them...
| dependencies = [ | |
| "matplotlib", | |
| "networkx", | |
| "numpy>=2", | |
| "opt_einsum", | |
| "quimb", | |
| "scipy", | |
| "sympy", | |
| "typing_extensions", | |
| ] | |
| dependencies = [ | |
| "matplotlib==3.10.8", | |
| "networkx==3.6.1", | |
| "numpy==2.4.4", | |
| "quimb==1.13.0", | |
| "scipy==1.17.1", | |
| "sympy==1.14.0", | |
| "typing_extensions==4.15.0", | |
| ] |
Also, I believe that opt_einsum is not used in the codebase (tests pass without), but could someone else double check please?
| enable-cache: true | ||
| cache-dependency-glob: "pyproject.toml" |
There was a problem hiding this comment.
It's suggested to pin the uv version as well
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| version: "0.11.3" # Install a specific version of uv. | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" |
| - name: "Set up Python ${{ matrix.python }}" | ||
| run: uv python install ${{ matrix.python }} |
There was a problem hiding this comment.
Is there a difference between this and setting
with:
python-version: ${{ matrix.python }}
in the previous action as shown in the docs ?
| if TYPE_CHECKING: | ||
| from collections.abc import Callable | ||
|
|
||
| nox.options.default_venv_backend = "uv" |
There was a problem hiding this comment.
Let's keep the default as a fallback
| nox.options.default_venv_backend = "uv" | |
| nox.options.default_venv_backend = "uv|virtualenv" |
|
|
||
| - run: nox --python ${{ matrix.python }} | ||
| - name: Run nox | ||
| run: uvx nox -db uv --python ${{ matrix.python }} |
There was a problem hiding this comment.
Two questions:
- If I understood correctly this comment, it seems that
noxinstalls the appropriate Python version. Does this mean that we can skip theuv python install ...above ? - Is there a reason why we are doing
uvx noxinstead ofuv run nox?
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| enable-cache: true |
There was a problem hiding this comment.
See comments in ci.yml about versions
This PR changes Graphix to use
uvinstead ofpipin thenoxroutine for CI tests.To adhere to the requirements of
uv, it also includes auv.lockfile locking dependencies for CI reproducibility, and has merged requirements into thepyproject.tomlfile in line with PEP best practice (https://packaging.python.org/en/latest/specifications/pyproject-toml/). A new Github action has been created to check the uv lockfile matches the pyproject.The installation process remains the same with this change - either
pip install -e .oruv sync(the latter preferred for reproducibility and speed). See changes to theCONTRIBUTING.mdandREADME.mdfor more details.This PR also turns off
ruffpreview mode, to keep linting more stable, alongside changing the dependabot to useuv. Changes to Graphix internal files are due to linting changes introduced by this reversion.